package com.sky.listener;

import org.springframework.boot.context.event.ApplicationFailedEvent;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

public class MyListener implements ApplicationListener {
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        // applicationEvent event 对应的就是发布的事件,applicationReadyEvent,applicationFailedEvent等等
        if (event instanceof ApplicationReadyEvent){
            System.out.println("my listener: application 容器初始化成功");
        }
        if (event instanceof ApplicationFailedEvent){
            System.out.println("my listener: application 容器初始化失败");
        }
    }
}
